package eu.veldsoft.cruce;

import java.awt.Color;
import java.awt.Frame;
import java.awt.TextArea;
import java.awt.event.KeyAdapter;
import java.awt.event.KeyEvent;

import javax.swing.BorderFactory;
import javax.swing.Box;

public class WINDOW {

	public Frame frame;
	public Box box;
	public int pressedKey;
	
	public WINDOW() {
		super();
	}
	
	public WINDOW(int rows, int cols, int x, int y) {
		super();
		// some simple Frame implementation
		// - Milen Pankov
		frame = new Frame("trumpAndTurnWindow");
        frame.setBounds(x, y, cols, rows);
        frame.setVisible(true);

    	box = Box.createVerticalBox();
    	frame.add(box);
	}
	
	public void drawBorder(int v, int h) {
		// draw simple border on the box
		box.setBorder(BorderFactory.createEmptyBorder(h, v, h, v));
	}
	
	public void addText(String text) {
		TextArea textArea = new TextArea(text);
		textArea.setEditable(false);
		box.add(textArea);
	}
	
	public void addText(String text, int color) {
		TextArea textArea = new TextArea(text);
		textArea.setEditable(false);
		textArea.setForeground(new Color(color));
		box.add(textArea);
	}
	
	public void refresh() {
		box.repaint();
	}
	
	public void wclear() {
		
	}
	
	public void delwin() {
		
	}
	
	public void move(int x, int y) {
		
	}
	
	public void keypad(boolean buffering) {
		frame.addKeyListener(new KeyAdapter() {
		    
			@Override
			public void keyPressed(KeyEvent keyEvent) {
				pressedKey = keyEvent.getKeyCode();
		    }

		});
	}
	
	public int wgetch() {
		return pressedKey;
	}
}
